<?php
// +----------------------------------------------------------------------
// | SL 2018.8.17
// +----------------------------------------------------------------------
// | Copyright (c) 2018~2018 http://sl.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: zq <1040657944@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\admin\model\UserModel;
use think\Controller;
use think\Db;
use think\Session;


class Index extends Base
{
    /**
     * 首页面板内容
    */
    public function indexPage()
    {
        return $this->fetch("index");
    }

    /**
     * 操作日志
    */
    public function operation()
    {
        if(request()->isAjax()){
            $param = input("param.");

            $limit = $param['limit'];
            $offset = ($param['page'] - 1) * $limit;
            $login_log = Db::table("z_login_log")->limit($offset,$limit)->select();
            $user = new UserModel();
            foreach($login_log as $key=>$vo){
                $user_info = $user->getOneUser(['id' => $vo['u_id']]);
                $login_log[$key]['username'] = $user_info['username'];
                $login_log[$key]['create_time'] = date("Y-m-d H:i:s",$vo['time']);

            }
            $return['count'] =  Db::table("z_login_log")->count();;  //总数据
            $return['code'] = "0"; //状态码
            $return['data'] = $login_log;
            return json($return);
        }
        return $this->fetch();
    }

}